﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;

namespace mForum.Web.Common.Infrastructure.AssetManager
{
    public class AssetType
    {
        private static Dictionary<string, string> _typesDictionary = new Dictionary<string, string>();
        private static Dictionary<string, string> _typesPathDictionary = new Dictionary<string, string>();

        public static string Script = "Script";
        public static string Stylesheet = "Stylesheet";                      

        static AssetType()
        {
            _typesDictionary.Add("Script", "<script src=\"{0}?d={1}&t={2}\" type=\"text/javascript\"></script>");
            _typesDictionary.Add("Stylesheet", "<link rel=\"stylesheet\" type=\"text/css\" href=\"{0}?d={1}&t={2}\" />");

            _typesPathDictionary.Add("Script", "~/Scripts/");
            _typesPathDictionary.Add("Stylesheet", "~/Content/");
        }

        public static Dictionary<string, string> AssetTypeDictionary
        {
            get { return _typesDictionary; }
        }

        public static string GetReferenceForType(string type)
        {
            if (!_typesDictionary.ContainsKey(type))
                throw new NullReferenceException();

            return _typesDictionary[type];
        }

        public static string GetBasePathForType(string type)
        {
            if (!_typesPathDictionary.ContainsKey(type))
                throw new NullReferenceException();

            return _typesPathDictionary[type];
        }
    }
}
